package com.bwie.controller;

import com.bwie.bean.Acc;
import com.bwie.bean.Types;
import com.bwie.service.AccService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class AccController {

    @Resource
    private AccService accService;


    @RequestMapping("list.do")
    public String list(
            @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
            String zyid,
            String sta,
            String ends,
            Model model){

        Map map = new HashMap();
        map.put("zyid",zyid);
        map.put("sta",sta);
        map.put("ends",ends);


        PageHelper.startPage(pageNum,3);
        List list=accService.list(map);
        PageInfo pageInfo = new PageInfo(list);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("map",map);
        return "list";

    }

    @RequestMapping("dels.do")
    @ResponseBody
    public Object dels(String aids){
       int i= accService.dels(aids);
       return i;
    }

    @RequestMapping("addto.do")
    public String addto(){
        return "add";
    }

    @RequestMapping("add.do")
    @ResponseBody
    public Object add(Acc acc){
       int i= accService.add(acc);
       return i;
    }


}





















